package com.Multi_threaded;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Test7 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        Callable<String> test6 = new Test6(50);
        //把callable的对象封装成一个FutureTask对象，（任务对象）
        FutureTask<String> stringFutureTask = new FutureTask<>(test6);
        new Thread(stringFutureTask).start();
        //获取线程执行完毕后的结果
        //注意：会等待上面的进程执行完毕后才进行下面的进程。
        String s = stringFutureTask.get();
        System.out.println(s);
    }
}
